<script setup lang="ts">
import { invoke } from '@tauri-apps/api/core';
import { reactive, ref } from 'vue';
// 导入库

import { useRouter } from "vue-router";
import { load_rtdata_subscriber_service_dxc, load_user_dxc, load_xcom_service_dxc } from './dxc';
import * as xcomService from "@/assets/api/xcomservice_0_0_1";
// 构建 router 对象
const router = useRouter()


const connectToRealtimeNode = async()=>{
  const res = await xcomService.BuildChannel({
    node_url: "dxm://127.0.0.1:9098",
    is_keep: true
  });

  console.log(res);
};

// 初始化 xPort
const onInitxPort = async () => {
  const is_init = await invoke("is_init_xport");
  if (!is_init) {
    await invoke("boot_xport");
    await load_xcom_service_dxc();
    console.log("加载用户组件。。。")
    await load_user_dxc();
    console.log("加载行情组件。。。")
    await load_rtdata_subscriber_service_dxc(); 
    await connectToRealtimeNode();
  }
};
// 进入页面，开始初始化
const onInit = async () => {
  await onInitxPort();
};

onInit()

</script>
<template>
  <router-view/>
</template>
<style lang="scss" scoped>
// 
// .btn {
//   // 修改按钮的边框为 红色
//   border: 1px solid red;
//   // 修改字体的颜色为蓝色
//   color: blue;
//   // 修改上边距为 10 个像素
//   margin-top: 10px;
//   // 修改左边距为 10 个像素
//   margin-left: 10px;
//   // 修改按钮宽度为 40 像素
//   width: 40px;
//   margin-right: 10px;
// }

// .form-wrapper {
//   margin-top: 20px;
//   margin-left: 20px;
//   width: 400px;
// }
</style>